﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.Revit;

namespace HYFloorPipeModule
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class HYDrawFloorPipes : HYNoTranExternalCommand
	{
		public override Result HYExecute()
		{
			string text = "DrawFloorPipe";
			Transaction transaction = new Transaction(base.Doc, text);
			try
			{
				transaction.Start();
				new RectFloorPipe(base.UiApp, base.Sel).StartDraw();
				transaction.Commit();
			}
			catch (Autodesk.Revit.Exceptions.OperationCanceledException)
			{
				transaction.Commit();
			}
			catch (Exception ex)
			{
				YJKMessageBox.Information(ex.Message);
				if (transaction != null && (int)transaction.GetStatus() != 3)
				{
					transaction.RollBack();
				}
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
